<template>
	<div>
		<autoDetailTable
			v-if="detail_type==='autotest'"
			:table_data="detail_table_data"
			:dataCount="dataCount"
		></autoDetailTable>
		<detailTable v-else :table_data="detail_table_data" :dataCount="dataCount"></detailTable>
	</div>
</template>
<script>
import footable from '@/components/devops/footable.vue';
import detailTable from '@/components/devops/detailTableData.vue';
import autoDetailTable from '@/components/devops/autoTestDetailTable.vue';
import { getHeader } from '@/app.config'

export default {
	name: 'detail_page',
	components: {
		footable,
		detailTable,
		autoDetailTable
	},
	data() {
		return {
			common: JSON.parse(localStorage.getItem('devops_common')),
			detail_table_data: [],
			dataCount: 0,
			url: '',
			detail_type: String
		};
	},
	mounted() {
		var proj_date = this.$route.params.proj_date;
		const projname = proj_date.split('_@_')[0];
		const date = proj_date.split('_@_')[1];
		this.detail_type = proj_date.split('_@_')[2];
		var url =
			process.env.VUE_APP_KANBAN_HOST +
			'/api/devops/table_detail?project=' +
			projname +
			'&date=' +
			date +
			'&type=' +
			this.detail_type;
		var self = this;
		this.$axios.get(url, {headers: getHeader()}).then(function(response) {
			if (response.status === 200) {
				if (response.data.code === 200) {
					var data = response.data;
					self.detail_table_data = data;
					self.dataCount = self.detail_table_data.count;
				} else {
					self.dataCount = 0;
				}
			}
		});
	}
};
</script>
